package databases

import (
	"fmt"
	"github.com/go-redis/redis/v8"
	"queue-gateway/config"
)

var Rdb *redis.Client

// type
func init() {

	Rdb = redis.NewClient(&redis.Options{
		Addr:     config.App.Redis.Addr,
		Password: config.App.Redis.Password,
		DB:       0,
		PoolSize: 20,
	})
	_, err := Rdb.Ping(Rdb.Context()).Result()
	if err != nil {
		fmt.Println("ping redis failed err:", err)
		panic(err)
	}
}

func GetVal(key string) string {
	result := Rdb.Get(Rdb.Context(), key)
	return result.Val()
}
